<?php

use think\facade\Route;
use think\facade\Config;
use think\Response;

//服务接口
Route::group(function () {

})->option(['mark' => 'serve', 'mark_name' => '服务接口']);

//无授权接口
Route::group(function () {
    Route::rule('v1/Login/createCaptcha', 'api/admin.setting.LoginController/createCaptcha');
    Route::rule('v1/Login/login', 'api/admin.setting.LoginController/login');
})->option(['mark' => 'base', 'mark_name' => '基础接口']);

//需授权接口
Route::group(function () {

    //权限设置
    Route::group(function () {
        //用户管理
        Route::group(function () {
            Route::get('/setting/user/get/:id', 'api/admin.setting.UserController/get')->name('get')->option(['real_name' => '用户详情']);
            Route::get('/setting/user/select', 'api/admin.setting.UserController/select')->name('select')->option(['real_name' => '用户列表']);
            Route::post('/setting/user/update', 'api/admin.setting.UserController/update')->name('update')->option(['real_name' => '用户更新']);
            Route::post('/setting/user/delete', 'api/admin.setting.UserController/delete')->name('delete')->option(['real_name' => '用户删除']);
            Route::post('/setting/user/insert', 'api/admin.setting.UserController/insert')->name('insert')->option(['real_name' => '用户插入']);
        })->option(['parent' => 'user', 'cate_name' => '用户设置']);

        //角色管理
        Route::group(function () {
            Route::get('/setting/role/get/:id', 'api/admin.setting.RoleController/get')->name('get')->option(['real_name' => '角色详情']);
            Route::get('/setting/role/select', 'api/admin.setting.RoleController/select')->name('select')->option(['real_name' => '角色列表']);
            Route::post('/setting/role/update', 'api/admin.setting.RoleController/update')->name('update')->option(['real_name' => '角色更新']);
            Route::post('/setting/role/delete', 'api/admin.setting.RoleController/delete')->name('delete')->option(['real_name' => '角色删除']);
            Route::post('/setting/role/insert', 'api/admin.setting.RoleController/insert')->name('insert')->option(['real_name' => '角色插入']);
        })->option(['parent' => 'role', 'cate_name' => '角色管理']);

        //菜单管理
        Route::group(function () {
            Route::get('/setting/permission/get/:id', 'api/admin.setting.PermissionController/get')->name('get')->option(['real_name' => '菜单详情']);
            Route::get('/setting/permission/rule', 'api/admin.setting.PermissionController/permission')->name('unique')->option(['real_name' => '权限菜单']);
            Route::get('/setting/permission/select', 'api/admin.setting.PermissionController/select')->name('select')->option(['real_name' => '菜单列表']);
            Route::post('/setting/permission/update', 'api/admin.setting.PermissionController/update')->name('update')->option(['real_name' => '菜单更新']);
            Route::post('/setting/permission/delete', 'api/admin.setting.PermissionController/delete')->name('delete')->option(['real_name' => '菜单删除']);
            Route::post('/setting/permission/insert', 'api/admin.setting.PermissionController/insert')->name('insert')->option(['real_name' => '菜单插入']);

        })->option(['parent' => 'permission', 'cate_name' => '菜单管理']);

    })->option(['parent' => 'setting', 'cate_name' => '权限管理']);

    //个人资料
    Route::group(function () {
        Route::get('account/info/:id', 'api/admin.setting.AccountController/info')->name('info')->option(['real_name' => '基本资料']);
        Route::post('account/update', 'api/admin.setting.AccountController/update')->name('update')->option(['real_name' => '信息修改']);
        Route::post('account/password', 'api/admin.setting.AccountController/password')->name('password')->option(['real_name' => '修改密码']);
    })->option(['parent' => 'account', 'cate_name' => '个人资料']);

    //部门管理
    Route::group(function () {
        Route::get('/setting/dept/get/:id', 'api/admin.setting.DeptController/get')->name('get')->option(['real_name' => '部门详情']);
        Route::get('/setting/dept/select', 'api/admin.setting.DeptController/select')->name('select')->option(['real_name' => '部门列表']);
        Route::post('/setting/dept/update', 'api/admin.setting.DeptController/update')->name('update')->option(['real_name' => '部门更新']);
        Route::post('/setting/dept/delete', 'api/admin.setting.DeptController/delete')->name('delete')->option(['real_name' => '部门删除']);
        Route::post('/setting/dept/insert', 'api/admin.setting.DeptController/insert')->name('insert')->option(['real_name' => '部门插入']);
    })->option(['parent' => 'dept', 'cate_name' => '部门管理']);

    //岗位
    Route::group(function () {
        Route::get('/setting/position/get/:id', 'api/admin.setting.PositionsController/get')->name('get')->option(['real_name' => '岗位详情']);
        Route::get('/setting/position/select', 'api/admin.setting.PositionsController/select')->name('select')->option(['real_name' => '岗位列表']);
        Route::post('/setting/position/update', 'api/admin.setting.PositionsController/update')->name('update')->option(['real_name' => '岗位更新']);
        Route::post('/setting/position/delete', 'api/admin.setting.PositionsController/delete')->name('delete')->option(['real_name' => '岗位删除']);
        Route::post('/setting/position/insert', 'api/admin.setting.PositionsController/insert')->name('insert')->option(['real_name' => '岗位插入']);
    })->option(['parent' => 'post', 'cate_name' => '岗位管理']);

    //字典设置
    Route::group(function () {
        Route::get('/setting/dict/get/:name', 'api/admin.setting.DictController/get')->name('get')->option(['real_name' => '字典详情']);
        Route::get('/setting/dict/select', 'api/admin.setting.DictController/select')->name('select')->option(['real_name' => '字典列表']);
        Route::post('/setting/dict/update', 'api/admin.setting.DictController/update')->name('update')->option(['real_name' => '字典更新']);
        Route::post('/setting/dict/delete', 'api/admin.setting.DictController/delete')->name('delete')->option(['real_name' => '字典删除']);
        Route::post('/setting/dict/insert', 'api/admin.setting.DictController/insert')->name('insert')->option(['real_name' => '字典插入']);
    })->option(['parent' => 'dict', 'cate_name' => '字典设置']);
    //附件管理
    Route::group(function () {
        Route::get('/setting/upload/get/:id', 'api/admin.setting.UploadController/get')->name('get')->option(['real_name' => '附件详情']);
        Route::get('/setting/upload/select', 'api/admin.setting.UploadController/select')->name('select')->option(['real_name' => '附件列表']);
        Route::post('/setting/upload/update', 'api/admin.setting.UploadController/update')->name('update')->option(['real_name' => '附件更新']);
        Route::post('/setting/upload/delete', 'api/admin.setting.UploadController/delete')->name('delete')->option(['real_name' => '附件删除']);
        Route::post('/setting/upload/insert', 'api/admin.setting.UploadController/insert')->name('insert')->option(['real_name' => '附件插入']);
        Route::post('/setting/upload/avatar', 'api/admin.setting.UploadController/avatar')->name('avatar')->option(['real_name' => '网站Logo']);
    })->option(['parent' => 'upload', 'cate_name' => '附件管理']);

    //系统配置
    Route::group(function () {
        Route::get('/setting/config/get/:name', 'api/admin.setting.ConfigController/get')->name('get')->option(['real_name' => '配置详情']);
        Route::post('/setting/config/update', 'api/admin.setting.ConfigController/update')->name('update')->option(['real_name' => '配置更新']);
    })->option(['parent' => 'config', 'cate_name' => '配置管理']);

    //消息管理
    Route::group(function () {
        Route::get('/setting/message', 'api/admin.setting.MessageController/message')->name('select')->option(['real_name' => '消息列表']);
    })->option(['parent' => 'config', 'cate_name' => '消息管理']);

})
    ->middleware(\app\api\common\middleware\AdminAuthTokenMiddleware::class, true)
    ->middleware(\app\api\common\middleware\AdminAuthPermissionMiddleware::class)
    ->middleware(\app\api\common\middleware\AdminLogMiddleware::class);

//找不到对应控制器404
Route::miss(function () {
    return ret_value(-1,'404','',404);
});
